Skip to content

Add switch level to paths for Show Environment All on C9400s#961

Merged
omehrabi merged 6 commits into
CiscoTestAutomation:mainfrom
aknopper:showplat9400sw
Oct 23, 2025
Merged

Add switch level to paths for Show Environment All on C9400s#961
omehrabi merged 6 commits into
CiscoTestAutomation:mainfrom
aknopper:showplat9400sw

Conversation

@aknopper
Copy link
Copy Markdown
Contributor

@aknopper aknopper commented Oct 6, 2025

Description

Fixes #958
Switches are included in the "show environment all" output on the CLI, but not being parsed for each switch

Motivation and Context

Now for 9400s with multiple switches, we can parse all power supply and fantray info.

Impact (If any)

New paths, but should support more cases

Screenshots:

show_plat_paths

Checklist:

  • I have updated the changelog.
  • I have updated the documentation (If applicable).
  • I have added tests to cover my changes (If applicable).
  • All new and existing tests passed.
  • All new code passed compilation.

@aknopper aknopper requested a review from a team as a code owner October 6, 2025 20:02
@aknopper aknopper requested review from Taarini and omehrabi October 6, 2025 20:02
@aknopper aknopper changed the title Add switch level to paths Add switch level to paths for Show Environment All on C9400s Oct 6, 2025
@aknopper
Copy link
Copy Markdown
Contributor Author

@ThomasJRyan Any chance you can look at this?

Copy link
Copy Markdown
Collaborator

@ThomasJRyan ThomasJRyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's overall good, but due to the schema change this will need to be a revision rather than a modification

Comment on lines +181 to +198
'switch': {
Any(): {
'power_supply': {
'slot': {
Any(): {
'model_no': str,
'type': str,
'capacity': str,
'status': str,
'fan_1_state': str,
'fan_2_state': str,
}
},
'current_configuration_mode': str,
'current_operating_state': str,
'currently_active': int,
'currently_available': int,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of an issue. Due to our strict adherence to backwards compatibility we can't change schemas like this. It has the potential to break older testscripts which we cannot have happen.

We do have a concept of revisions to address this however. It allows us to introduce new revisions of parsers without breaking backwards compatibility.

You can read up on them here https://pubhub.devnetcloud.com/media/pyats-development-guide/docs/writeparser/writeparser.html#revising-a-parser

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placed it in /genie/parser/libs/iosxe/rv2/show_platform.py

Comment thread src/genie/libs/parser/iosxe/cat9k/c9400/show_platform.py Outdated
Copy link
Copy Markdown
Collaborator

@ThomasJRyan ThomasJRyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. If I can ask you to provide some unittests I'll be able to approve!

@aknopper
Copy link
Copy Markdown
Contributor Author

aknopper commented Oct 17, 2025

I added the output files, however I wasn't able to test this locally:

(.venv) alexknop@Alexs-MacBook-Pro tests % python3 folder_parsing_job.py -o iosxe -c ShowEnvironmentAll
Traceback (most recent call last):
  File "/Users/alexknop/Coding Projects/genieparser/tests/folder_parsing_job.py", line 1, in <module>
    from genie.libs.parser.utils.unittests import main
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/genie/libs/parser/__init__.py", line 16, in <module>
    from .base import tcl_invoke_ats_cmd,\
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/genie/libs/parser/base.py", line 17, in <module>
    from genie.metaparser import MetaParser
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/genie/metaparser/__init__.py", line 4, in <module>
    from ._metaparser import *
  File "src/genie/metaparser/_metaparser.py", line 11, in init genie.metaparser._metaparser
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/unicon/__init__.py", line 16, in <module>
    __plugin_manager__.discover_builtin_plugins()
  File "src/unicon/core/pluginmanager.py", line 258, in unicon.core.pluginmanager.PluginManager.discover_builtin_plugins
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/unicon/plugins/aireos/__init__.py", line 2, in <module>
    from unicon.plugins.generic import ServiceList, GenericSingleRpConnection, GenericDualRPConnection
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/unicon/plugins/generic/__init__.py", line 30, in <module>
    from unicon.bases.routers.connection import BaseSingleRpConnection
  File "src/unicon/bases/routers/connection.py", line 20, in init unicon.bases.routers.connection
ModuleNotFoundError: No module named 'ats'
(.venv) alexknop@Alexs-MacBook-Pro tests % 

Does this module need to be pyats and not ats?

I also wonder if putting these revised parsers in the iosxe folder is going to affect other platforms? This is 9400 specific, will genie be able to use the revised one in the iosxe folder if i've defined my device with a model of c9400?

@ThomasJRyan
Copy link
Copy Markdown
Collaborator

I added the output files, however I wasn't able to test this locally:

(.venv) alexknop@Alexs-MacBook-Pro tests % python3 folder_parsing_job.py -o iosxe -c ShowEnvironmentAll
Traceback (most recent call last):
  File "/Users/alexknop/Coding Projects/genieparser/tests/folder_parsing_job.py", line 1, in <module>
    from genie.libs.parser.utils.unittests import main
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/genie/libs/parser/__init__.py", line 16, in <module>
    from .base import tcl_invoke_ats_cmd,\
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/genie/libs/parser/base.py", line 17, in <module>
    from genie.metaparser import MetaParser
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/genie/metaparser/__init__.py", line 4, in <module>
    from ._metaparser import *
  File "src/genie/metaparser/_metaparser.py", line 11, in init genie.metaparser._metaparser
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/unicon/__init__.py", line 16, in <module>
    __plugin_manager__.discover_builtin_plugins()
  File "src/unicon/core/pluginmanager.py", line 258, in unicon.core.pluginmanager.PluginManager.discover_builtin_plugins
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/unicon/plugins/aireos/__init__.py", line 2, in <module>
    from unicon.plugins.generic import ServiceList, GenericSingleRpConnection, GenericDualRPConnection
  File "/Users/alexknop/Coding Projects/genieparser/.venv/lib/python3.9/site-packages/unicon/plugins/generic/__init__.py", line 30, in <module>
    from unicon.bases.routers.connection import BaseSingleRpConnection
  File "src/unicon/bases/routers/connection.py", line 20, in init unicon.bases.routers.connection
ModuleNotFoundError: No module named 'ats'
(.venv) alexknop@Alexs-MacBook-Pro tests % 

Does this module need to be pyats and not ats?

I also wonder if putting these revised parsers in the iosxe folder is going to affect other platforms? This is 9400 specific, will genie be able to use the revised one in the iosxe folder if i've defined my device with a model of c9400?

We actually override the ats namespace interally so you are able to import from ats or pyats without issue. The only reason I could see you getting this issue is if you don't have pyats installed. I know I'm asking rather mundane troubleshooting questions, but can you ensure you have pyats installed please with a pip install | grep pyats

@aknopper
Copy link
Copy Markdown
Contributor Author

@ThomasJRyan Yes, I have pyats installed:

(.venv) alexknop@Alexs-MacBook-Pro genieparser % pip list installed | grep pyats
pyats                        25.9
pyats.aereport               25.9
pyats.aetest                 25.9
pyats.async                  25.9
pyats.connections            25.9
pyats.datastructures         25.9
pyats.easypy                 25.9
pyats.kleenex                25.9
pyats.log                    25.9
pyats.reporter               25.9
pyats.results                25.9
pyats.tcl                    25.9
pyats.topology               25.9
pyats.utils                  25.9

@ThomasJRyan
Copy link
Copy Markdown
Collaborator

ThomasJRyan commented Oct 20, 2025

So the good and bad news is that I can pull your PR into a fresh pyats environment, run the tests, and not get the error you're seeing. Which means it's likely an environment error that can be resolved with a fresh environment install. Though it does seem that the unittest isn't passing which is a concern...

python3 folder_parsing_job.py -o iosxe -c ShowEnvironmentAll
/home/thomryan/external_pyats/genieparser/src/genie/libs/parser/utils/common.py:12: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
<module 'pyats.aetest.testscript.unittests' from '/home/thomryan/external_pyats/genieparser/src/genie/libs/parser/utils/unittests.py'>
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: |                   Starting testcase SuperFileBasedTesting                    |
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: |                            Starting section setup                            |
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %SCRIPT-WARNING: Equal unittests for iosxe -> rv2 -> ShowEnvironmentAll don't exist
2025-10-20T14:53:47: %AETEST-INFO: The result of section setup is => PASSED
2025-10-20T14:53:47: %AETEST-INFO: The result of testcase SuperFileBasedTesting is => PASSED
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: |                           Starting testcase iosxe                            |
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: |                            Starting section setup                            |
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: The result of section setup is => PASSED
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: |                     Starting section ShowEnvironmentAll                      |
2025-10-20T14:53:47: %AETEST-INFO: +------------------------------------------------------------------------------+
2025-10-20T14:53:47: %AETEST-INFO: +..............................................................................+
2025-10-20T14:53:47: %AETEST-INFO: :                 Starting STEP 1: iosxe -> ShowEnvironmentAll                 :
2025-10-20T14:53:47: %AETEST-INFO: +..............................................................................+
2025-10-20T14:53:47: %AETEST-INFO: +..............................................................................+
2025-10-20T14:53:47: %AETEST-INFO: :        Starting STEP 1.1: Test Golden -> iosxe -> ShowEnvironmentAll         :
2025-10-20T14:53:47: %AETEST-INFO: +..............................................................................+
2025-10-20T14:53:47: %AETEST-INFO: +..............................................................................+
2025-10-20T14:53:47: %AETEST-INFO: :    Starting STEP 1.1.1: Gold -> iosxe -> ShowEnvironmentAll -> golden_out    :
2025-10-20T14:53:47: %AETEST-INFO: :                                     put2                                     :
2025-10-20T14:53:47: %AETEST-INFO: +..............................................................................+
2025-10-20T14:53:47: %AETEST-INFO: The result of STEP 1.1.1: Gold -> iosxe -> ShowEnvironmentAll -> golden_output2 is => PASSED
2025-10-20T14:53:47: %AETEST-INFO: +..............................................................................+
2025-10-20T14:53:47: %AETEST-INFO: :    Starting STEP 1.1.2: Gold -> iosxe -> ShowEnvironmentAll -> golden_out    :
2025-10-20T14:53:47: %AETEST-INFO: :                                     put3                                     :
2025-10-20T14:53:47: %AETEST-INFO: +..............................................................................+
2025-10-20T14:53:47: %SCRIPT-ERROR: Traceback (most recent call last):
2025-10-20T14:53:47: %SCRIPT-ERROR:   File "/home/thomryan/external_pyats/genieparser/src/genie/libs/parser/utils/unittests.py", line 607, in test_golden
2025-10-20T14:53:47: %SCRIPT-ERROR:     parsed_output = obj.parse(**arguments)
2025-10-20T14:53:47: %SCRIPT-ERROR:                     ^^^^^^^^^^^^^^^^^^^^^^
2025-10-20T14:53:47: %SCRIPT-ERROR:   File "src/genie/metaparser/_metaparser.py", line 329, in genie.metaparser._metaparser.MetaParser.parse
2025-10-20T14:53:47: %SCRIPT-ERROR:   File "src/genie/metaparser/_metaparser.py", line 322, in genie.metaparser._metaparser.MetaParser.parse
2025-10-20T14:53:47: %SCRIPT-ERROR:   File "src/genie/metaparser/util/schemaengine.py", line 233, in genie.metaparser.util.schemaengine.Schema.validate
2025-10-20T14:53:47: %SCRIPT-ERROR: genie.metaparser.util.exceptions.SchemaEmptyParserError: Parser Output is empty
Caught an assertion failure while executing STEP 1.1.2: Gold -> iosxe -> ShowEnvironmentAll -> golden_output3:
Traceback (most recent call last):
  File "/home/thomryan/external_pyats/genieparser/src/genie/libs/parser/utils/unittests.py", line 655, in test_golden
    raise AssertionError("Device output and expected output do not match")
AssertionError: Device output and expected output do not match

My environment

> pip list | grep pyats
genie.libs.parser            25.9        /home/thomryan/external_pyats/genieparser
pyats                        25.9
pyats.aereport               25.9
pyats.aetest                 25.9
pyats.async                  25.9
pyats.connections            25.9
pyats.contrib                25.9
pyats.datastructures         25.9
pyats.easypy                 25.9
pyats.kleenex                25.9
pyats.log                    25.9
pyats.reporter               25.9
pyats.results                25.9
pyats.robot                  25.9
pyats.tcl                    25.9
pyats.topology               25.9
pyats.utils                  25.9
> pip list | grep unicon
unicon                       25.9
unicon.plugins               25.9
> pip list | grep genie
genie                        25.9
genie.libs.clean             25.9
genie.libs.conf              25.9
genie.libs.filetransferutils 25.9
genie.libs.health            25.9
genie.libs.ops               25.9
genie.libs.parser            25.9        /home/thomryan/external_pyats/genieparser
genie.libs.robot             25.9
genie.libs.sdk               25.9
genie.telemetry              25.9
genie.trafficgen             25.9

Importantly, it seems the tests aren't being picked up

Equal unittests for iosxe -> rv2 -> ShowEnvironmentAll don't exist

Likely just because you haven't moved them into the rv2 folder

@aknopper
Copy link
Copy Markdown
Contributor Author

Okay we should be good now

@aknopper aknopper requested a review from ThomasJRyan October 22, 2025 23:31
@omehrabi omehrabi merged commit f88eece into CiscoTestAutomation:main Oct 23, 2025
5 checks passed
@aknopper aknopper mentioned this pull request Nov 24, 2025
5 tasks
@aknopper
Copy link
Copy Markdown
Contributor Author

@ThomasJRyan It looks like this was removed for the 25.10 release.
Question though, does this need to go under c9400/rv1 and not iosxe/rv2, since it is platform specific?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show Environment All - C9400s

3 participants